package com.hlg.xboot.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>Description: 字典表类型</p>
 * <p>Copyright: Copyright (c) 2017</p>
 * <p>Company: 智悦信息</p>
 * <p>Site: www.zhiyuesoft.com</p>
 *
 * @author tianzw
 * @version 1.0
 * @date 2017/07/04
 */
public enum DicType {
    Country("国籍","country"), Nation("民族","nation"), Party("党派", "party"), ProTitle("职称", "protitle"), Subject("学科", "subject"), NationCode("国民行业", "nation_code"),
    District("行政区划","district"), ProjectClassic("项目类型","project_classic"), LeaderUnit("主管单位", "leader_unit"), InnerClassic("校内项目类型","inner_classic")
    ;

    private String desc;
    private String value;


    DicType(String desc, String value) {
        this.desc = desc;
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static DicType getItem(String value) {
        DicType item = null;
        DicType[] items = DicType.values();
        for (DicType _item: DicType.values()) {
            if (_item.getValue().equals(value)) {
                item = _item;
                break;
            }
        }
        return item;
    }

    public static List toList() {
        List list = new ArrayList();
        for (DicType _item: DicType.values()) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("value",String.valueOf(_item.getValue()));
            map.put("desc", _item.getDesc());
            list.add(map);
        }
        return list;
    }
}
